package com.mall4jcola.cloud.auth.executor;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.cola.dto.SingleResponse;
import com.mall4jcola.cloud.auth.model.UserLoginInfo;
import com.mall4jcola.cloud.dto.data.UserAuthsTokenDTO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * TODO
 * 创建token执行器
 * @author hmxchen
 */
@Component
@AllArgsConstructor
public class AuthsTokenCreateCmdExe {


    public SingleResponse<UserAuthsTokenDTO> execute(UserLoginInfo data) {
        StpUtil.login(data.getUserId());
        return SingleResponse.of(BeanUtil.copyProperties(StpUtil.getTokenInfo(),UserAuthsTokenDTO.class));
    }
}
